#include "frame_depot_test.h"
#include "dag.h"

using namespace dag;

const char* FrameDepotTest::description() {
	return "frame_depot_test";
}

bool FrameDepotTest::run() {
	
	FrameSpec spec(10, 10, 10, 10);
	FrameDepot depot(spec);
	Frame frame(spec);
	
	for (size_t i = 0; i < 100; i++) {
		seed_random(frame);
		depot.add(frame);
	}
	
	if (depot.size() != 100) {
		return false;
	}
	
	Frame f2(spec);
	Frame f3(FrameSpec(1, 1, 1, 1));
	depot.fill(99, f2);
	
	try {
		depot.fill(99, f3);
		return false;
	}
	catch (InvalidArgument& err) {
	}
	
	if (!equal_frames(frame, f2)) {
		return false;
	}
	
	if (equal_frames(f2, f3)) {
		return false;
	}
	
	FrameDepot depot2(spec);
	if (equal_frame_depot(depot, depot2)) {
		return false;
	}
	
	depot2 = depot;
	if (!equal_frame_depot(depot2, depot)) {
		return false;
	}
	
	depot.clear();
	if (depot.size() != 0) {
		return false;
	}
	
	if (equal_frame_depot(depot, depot2)) {
		return false;
	}
	
	depot2.clear();
	if (!equal_frame_depot(depot, depot2)) {
		return false;
	}
	
	return true;
}